package com.java1412;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author java1412
 * @since 2023-10-27 15:55:06
 */
@SpringBootApplication
// 开启eureka的客户端
@EnableEurekaClient
// 开启服务发现,在注册中心中发现已经注册的服务
@EnableDiscoveryClient
// 开启断路器功能
@EnableHystrix
public class ServiceRibbonApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServiceRibbonApplication.class, args);
    }

    // 向IOC容器注册组件，restTemplate
    @Bean
    @LoadBalanced   // 开启负载均衡
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
